CC=gcc
FLAGS=`pkg-config pidgin xmms2-client xmms2-client-glib --cflags --libs` --shared -O2
DEBUG_CFLAGS=-g -g -Wall -Waggregate-return -Wcast-align -Wdeclaration-after-statement -Wendif-labels -Werror-implicit-function-declaration -Wextra -Wno-sign-compare -Wno-unused-parameter -Winit-self -Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wundef -Wp,-D_FORTIFY_SOURCE=2
SOURCE=xmms2-pidgin.c
TARGET=xmms2-pidgin.so
INSTALLDIR_LOCAL=~/.purple/plugins
INSTALLDIR_GLOBAL=/usr/lib/purple-2

all:
	$(CC) $(FLAGS) $(DEBUG_CFLAGS) $(SOURCE) -o $(TARGET)

install: install_local

install_global:
	if [ ! -d $(INSTALLDIR_GLOBAL) ]; then \
		mkdir $(INSTALLDIR_GLOBAL); \
	fi;
	cp $(TARGET) $(INSTALLDIR_GLOBAL)

install_local:
	if [ ! -d $(INSTALLDIR_LOCAL) ]; then \
		mkdir $(INSTALLDIR_LOCAL); \
	fi;
	cp $(TARGET) $(INSTALLDIR_LOCAL)

uninstall:
	if [ -f $(INSTALLDIR_LOCAL)/$(TARGET) ]; then rm $(INSTALLDIR_LOCAL)/$(TARGET); fi;
	if [ -f $(INSTALLDIR_GLOBAL)/$(TARGET) ]; then rm $(INSTALLDIR_GLOBAL)/$(TARGET); fi;

clean: 
	rm $(TARGET)
